package com.scujj.cs6.model.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.scujj.cs6.model.entity.WeatherForecast;
import com.scujj.cs6.model.entity.WeatherForecastWithCities;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDate;

/**
 * @TableName weather_forecast
 */
@Schema(name = "WeatherForecastVo", description = "未来天气视图对象")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WeatherForecastVo implements Serializable {
    @Schema(description = "白昼天气")
    @JsonProperty("text_day")
    private String textDay;
    @Schema(description = "夜晚天气")
    @JsonProperty("text_night")
    private String textNight;
    @Schema(description = "最高温度")
    @JsonProperty("high")
    private Integer high;
    @Schema(description = "最低温度")
    @JsonProperty("low")
    private Integer low;
    @Schema(description = "白昼风级")
    @JsonProperty("wc_day")
    private String wcDay;
    @Schema(description = "夜晚风级")
    @JsonProperty("wc_night")
    private String wcNight;
    @Schema(description = "白昼风向")
    @JsonProperty("wd_day")
    private String wdDay;
    @Schema(description = "夜晚风向")
    @JsonProperty("wd_night")
    private String wdNight;
    @Schema(description = "日期")
    @JsonProperty("date")
    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
    @JsonSerialize(using = LocalDateSerializer.class)
    @JsonDeserialize(using = LocalDateDeserializer.class)
    private LocalDate date;
    @Schema(description = "星期，北京时区")
    @JsonProperty("week")
    private String week;

    public WeatherForecastVo(WeatherForecast weatherForecast) {
        BeanUtils.copyProperties(weatherForecast, this);
    }

    public WeatherForecastVo(WeatherForecastWithCities weatherForecast) {
        BeanUtils.copyProperties(weatherForecast, this);
    }
}